﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using TouchRC.Classes;
using TouchRC.Templates;
using TouchRC.Logic;
using System.Drawing;
using Fluid.Drawing.GdiPlus;
using Fluid.Classes;

namespace TouchRC.ListBoxes
{
    public class ComputerListBox : TransparentListBox
    {
        #region Private Members

        private ComputerTemplate m_Template;

        #endregion

        #region Public Accessors

        public bool EditMode
        {
            set
            {
                if (m_Template.EditMode != value)
                {
                    m_Template.EditMode = true;
                    m_Template.EditMode = value; 
                }
            }
        }

        public List<ComputerListBoxItem> Computers { get; private set; }

        public ComputerSelectionPanel ComputersPanel { get { return Parent as ComputerSelectionPanel; } }

        public ComputerListBoxItem Item { get { return GetItem(SelectedItemIndex) as ComputerListBoxItem; } }

        #endregion

        protected override void InitControl()
        {
            base.InitControl();

            ItemHeight = AppSettings.BaseControlHeight + (AppSettings.BaseControlHeight / 8);

            m_Template = new ComputerTemplate();
            ItemTemplate = m_Template;
        }

        internal void UpdateData()
        {
            Computers = ConfigSettings.GetComputers();
            DataSource = Computers;
            UpdateHeight();
            this.SelectFirstDataItem();
        }
    }
}
